API Documentation
Public Member Functions | List of all members
nkScripts::ScriptManager Class Referencefinal

Manages the scripts available in the component. More...

Inheritance diagram for nkScripts::ScriptManager:

Public Member Functions

ScriptcreateOrRetrieve (const nkMemory::StringView &name)
 
Scriptget (const nkMemory::StringView &name)
 
ScriptgetByIndex (unsigned int id)
 
void rename (const nkMemory::StringView &currentName, const nkMemory::StringView &newName)
 
void erase (const nkMemory::StringView &name)
 

Detailed Description

Manages the scripts available in the component.

The manager always owns the memory allocated through it. External code should never call delete on memory retrieved through it.

Member Function Documentation

◆ createOrRetrieve()

Script* nkScripts::ScriptManager::createOrRetrieve ( const nkMemory::StringView name)

Creates if unavailable, or retrieves if available, a script given its name.

Parameters
nameThe name of the script to create or retrieve.
Returns
The script, possibly newly created.
Remarks
The manager is responsible for the memory returned. Deallocation should occur through ScriptManager::erase().

◆ get()

Script* nkScripts::ScriptManager::get ( const nkMemory::StringView name)

Gets an existing script.

Parameters
nameThe name of the script to retrieve.
Returns
The script attached to given name if available, nullptr if unavailable.

◆ getByIndex()

Script* nkScripts::ScriptManager::getByIndex ( unsigned int  id)

Gets a script according to an index.

Parameters
idThe index to search for.
Returns
The script linked to given index if available, nullptr if unavailable.
Remarks
If manager memory is manipulated between different calls to this method, it is possible indices return different scripts between the calls.

◆ rename()

void nkScripts::ScriptManager::rename ( const nkMemory::StringView currentName,
const nkMemory::StringView newName 
)

Renames a script within memory.

Parameters
currentNameThe current name to find back the script to alter.
newNameThe new name to assign to the script.

◆ erase()

void nkScripts::ScriptManager::erase ( const nkMemory::StringView name)

Erases a script, and free its memory.

Parameters
nameThe name of the script to erase.

The documentation for this class was generated from the following file: